package com.xxl.job.admin;

import com.xxl.job.admin.condition.ServletInitializerCondition;
import com.xxl.job.admin.util.EnvUtil;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Conditional;

/**
 * @author hujj
 * @version 1.0
 * @date 2021/6/2/002 13:58
 */
@Conditional(ServletInitializerCondition.class)
@SpringBootApplication(scanBasePackages = {
        "com.xxl",
})
public class XxlJobServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        String profile = System.getProperty("spring.profiles.active");
        EnvUtil.setProfile(profile);
        System.out.println("found commandline profile11: "+EnvUtil.getStaticProfile());

        String configLocation = System.getProperty("spring.config.location");
        System.out.println("found commandline configLocation12: "+configLocation);

        EnvUtil.setConfigLocation(configLocation);
        System.out.println("found commandline configLocation13: "+EnvUtil.getStaticConfigLocation());

        return application.sources(XxlJobServletInitializer.class);
    }
}
